<?php

namespace app\home\controller;

use app\home\lib\MyController;

// 操作记录
class MyLog extends MyController
{
	// 操作记录列表
	public function list()
	{
		$page = input('page');

		if (!isset($page) || $page < 1) {
			$page = 1;
		}

		$user_id = session("user_id");
		$user_name = session("user_name");

		$count = db('my_log')
			->where("user_id", $user_name . '_' . $user_id)
			->count();

		// 取得列表
		$allPage = ceil($count / $this->onePage);
		if ($page > $allPage) {
			$page = $allPage;
		}

		$list = db('my_log')
			->where("user_id", $user_name . '_' . $user_id)
			->order("id desc")
			->page($page, $this->onePage)
			->select();

		$this->assign('page', $page);
		$this->assign('count', $count);
		$this->assign('allpage', $allPage);
		$this->assign('list', $list);

		return $this->fetch();
	}
}
